//
//  ViewController.m
//  huiguigui
//
//  Created by on 17/4/20.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "ViewController.h"
#import "MD5String.h"


@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];

    int value = arc4random() % 5;
    NSLog(@"value = %d",value);
    
    //获取  需要的加密 签名
    [MD5String getSignatureStr:^(NSString *timestamp, NSString *nonceStr, NSString *signature)
    {
        NSLog(@"%@---%@---%@", [self SetTime:timestamp],nonceStr,signature);
    }];
    
}
//时间戳转换成时间
-(NSString*)SetTime:(NSString*)time
{
    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
    
    [formatter setDateStyle:NSDateFormatterMediumStyle];
    
    [formatter setTimeStyle:NSDateFormatterShortStyle];
    
    [formatter setDateFormat:@"yyyyMMddHHmmss"];
    
    int timeval = [time intValue];
    
    NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:timeval];
    
    NSString *confromTimespStr = [formatter stringFromDate:confromTimesp];
    
    NSLog(@"%@",confromTimespStr);
    
    NSDate *date = [[NSDate alloc]initWithTimeIntervalSince1970:time.longLongValue];
    NSLog(@"date === %@",date);
    
    return confromTimespStr;
}

@end
